package face.pay.util;


import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

@Data
public class ResponseMessage {

    private static Integer SUCCESS_CODE = 1;

    private static Integer FAIL_CODE = 0;


    private static String SUCCESS_MESSAGE = "操作成功";



    //1成功 0失败 接口调用结果
    private Integer code;

    //1成功 -1验签失败 -2参数有误
    private Integer errorCode;

    private String message;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Object data;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String sign;

    private String nonceStr;




    public static ResponseMessage createSuccess(String sign, Object data) {
        ResponseMessage result = new ResponseMessage();
        result.setCode(SUCCESS_CODE);
        result.setErrorCode(ErrorCode.SUCCESS_CODE);
        result.setMessage(SUCCESS_MESSAGE);
        result.setSign(sign);
        result.setData(data);
        return result;
    }

    public static ResponseMessage createSuccess( Object data) {
        ResponseMessage result = new ResponseMessage();
        result.setCode(SUCCESS_CODE);
        result.setErrorCode(ErrorCode.SUCCESS_CODE);
        result.setMessage(SUCCESS_MESSAGE);
        result.setData(data);
        return result;
    }

    public static ResponseMessage createSginFail() {

        ResponseMessage result = new ResponseMessage();
        result.setCode(FAIL_CODE);
        result.setErrorCode(ErrorCode.SIGN_FAIL_CODE);
        result.setMessage(ErrorCode.SIGN_FAIL_MESSAGE);
        return result;

    }

    public static ResponseMessage createParamFail() {
        ResponseMessage result = new ResponseMessage();
        result.setCode(FAIL_CODE);
        result.setErrorCode(ErrorCode.PARAM_FAIL_CODE);
        result.setMessage(ErrorCode.PARAM_FAIL_MESSAGE);
        return result;
    }

    public static ResponseMessage createFail(Integer errorCode,String message) {
        ResponseMessage result = new ResponseMessage();
        result.setCode(FAIL_CODE);
        result.setErrorCode(errorCode);
        result.setMessage(message);

        return result;
    }



}
